package com.abel.roommanager.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.abel.roommanager.pojo.Student;
public class StudentRegexUtil {
	
   public static boolean validateStudent(Object cl) throws ParseException {
	   boolean flag=true;
	   Student student=null;
	if(cl instanceof Student) {
		 student=(Student) cl;
	}
	Date date =new Date();
	String livetime=student.getLivetime();
	SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
	Date date2=simpleDateFormat.parse(livetime);
	  if (student.getCid()==0) {
		flag=false;
	}
	  else if (date2.getTime()-date.getTime()>0) {
		flag=false;
	}
	  else if (student.getRoomno()==0) {
		flag=false;
	}
	  else if(!(student.getSex()==1||student.getSex()==2)) {
		flag=false;
	}
	  else if (student.getSname().length()<2||student.getSname().length()>8) {
		flag=false;
	}
	  else if (!RegexUtil.isMobile(student.getTel())) {
		flag=false;
	}
	return flag;
	}  
}
